# @将实例方法作为装饰器

# 其实静态方法，类方法还有示例方法都是可以作为撞死其使用的

class Decorator():
    def __call__(self, origin):
        def inner(*args, **kwargs):
            print('begin')
            result = origin(*args, **kwargs)
            print('after')
            return result
        return inner

    def deco(self, origin):
        def inner(*args, **kwargs):
            print('deco')
            result = origin(*args, **kwargs)
            return result
        return inner

d = Decorator()
deco = Decorator().deco

@d
def test():
    print('test')

test()

@deco
def test2():
    print('test')

test2()
